package com.blogspot.security.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.blogspot.security.domain.ApplicationRole;
import com.blogspot.security.domain.ApplicationUser;
import com.blogspot.security.service.UserDetailsRegisterService;

@Controller
@RequestMapping("/register")
public class RegisterController {

	@Autowired
	UserDetailsRegisterService userDetailsRegisterService;
	
    @RequestMapping(method = RequestMethod.GET)
    public String getPage(Model model) {
    	ApplicationUser user = new ApplicationUser();
    	user.setUserName("AllanSung");
    	user.setPassword("1234");
    	ApplicationRole ar = new ApplicationRole();
    	ar.setId((long) 1);
    	ar.setRoleAuthName("App_Admin");
    	user.setRole(ar);
    	userDetailsRegisterService.insertApplicationUser(user);
        return "/register";
    }
}
